package vn.appsmobi.ulti;

import android.content.Context;
import android.widget.Toast;

public class ToastUtil
{
  private static Toast lastToast = null;

  public static void clear()
  {
    if (lastToast != null)
      lastToast.cancel();
  }

  public static void show(Context context, int resId)
  {
    show(context, context.getString(resId), 0);
  }

  public static void show(Context context, int resId, int duration)
  {
    show(context, context.getString(resId), duration);
  }

  public static void show(Context context, CharSequence text)
  {
    show(context, text, 0);
  }

  public static void show(Context context, CharSequence text, int duration)
  {
    if (lastToast != null)
      lastToast.cancel();
    Toast localToast = Toast.makeText(context, text, duration);
    lastToast = localToast;
    localToast.show();
  }
}
